/**
 * @projectName gs_online
 * @package com.answer.wx.gateway.controller
 * @className com.answer.wx.gateway.controller.NewsController
 */
package com.answer.wx.gateway.controller;

import com.answer.wx.common.aop.ApiOptions;
import com.answer.wx.common.response.ResponseListEntity;
import com.answer.wx.dao.model.*;
import com.answer.wx.gateway.bean.MessageBean;
import com.answer.wx.gateway.config.filter.RequestInfoHolder;
import com.answer.wx.gateway.service.MessageService;
import com.answer.wx.gateway.service.NewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * NewsController
 * @description 信息展示类
 * @author answer_wx
 * @date 2022/8/7 22:13
 * @version 1.0
 */
@RestController
@RequestMapping("/news")
@Api(value = "信息展示", tags = {"信息展示"})
@Slf4j
public class NewsController {
    @Autowired
    private NewsService newsService;
    @Autowired
    private MessageService messageService;

    @GetMapping("/swiper")
    @ApiOperation("展示所有轮播图")
    @ApiOptions
    public ResponseListEntity<Swiper> allSwiper() {
        return newsService.getAllSwiper();
    }

    @GetMapping("/shop")
    @ApiOperation("展示所有商品")
    @ApiOptions
    public ResponseListEntity<Shop> getAllShop() {
        return newsService.getAllShop();
    }

    @GetMapping("/categor")
    @ApiOperation("展示所有分类")
    @ApiOptions
    public ResponseListEntity<Categor> getAllCategory() {
        return newsService.getAllCategory();
    }

    @GetMapping("/notice")
    @ApiOperation("展示所有通知")
    @ApiOptions
    public ResponseListEntity<Notice> getAllNotice() {
        return newsService.getAllNotice();
    }

    @GetMapping("/getAllMessageDetail/{pageNumber}")
    @ApiOperation("展示第一页消息")
    @ApiOptions
    public List<MessageBean> getAllMessageDetail(@PathVariable Integer pageNumber) {
        return messageService.getAllMessageDetail(pageNumber);
    }

    @GetMapping("/lost")
    @ApiOperation("展示丢失物品")
    @ApiOptions
    List<Message> getLost() {
        return messageService.getLost();
    }

    @GetMapping("/getLastNewMessage/{userId}")
    @ApiOperation("展示最新消息")
    @ApiOptions
    public NewMessage getLastNewMessage(@PathVariable Integer userId) {
        return messageService.getLastNewMessage(userId);
    }


}